#include<bits/stdc++.h>
#define N 20005
using namespace std;
int n;
int a[N],b[N],id[N];
int z;
vector<pair<int,int> > g;
const int mx=1900000;
void calc(int x,int p){
    int l=x,r=x+p-1,c=b[l];
    for(int i=l+1;i<=r;i++) id[b[i]]--;
    id[c]=r;
    for(int i=l+1;i<=r;i++) b[i-1]=b[i];
    b[r]=c;
    g.push_back({1,x});
}
void sol(int p){
    g.clear();
    for(int i=1;i<=n;i++) b[i]=a[i],id[a[i]]=i;
    for(int i=n;i>=p;i--){
        while(id[i]+p-1<=i){
            calc(id[i],p);
            if(g.size()>mx) return;
        }
        while(id[i]!=i){
            calc(i-p+1,p);
            if(g.size()>mx) return;
        }
    }
    for(int i=1;i<=p-1;i++){
        int x=id[i];
        for(int j=x;j>i;j--){
            id[b[j-1]]=j;
            id[b[j]]=j-1;
            swap(b[j-1],b[j]);
            g.push_back({2,j-1});
            if(g.size()>mx) return;
        }
    }
    printf("%d %d\n",p,(int)g.size());
    for(pair<int,int> i:g) printf("%d %d\n",i.first,i.second);
    exit(0);
}
signed main(){
    freopen("rotate.in","r",stdin);
    freopen("rotate.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) b[i]=a[i],id[a[i]]=i;
    for(int i=1;i<=n;i++){
        int x=id[i];
        for(int j=x;j>i;j--){
            id[b[j-1]]=j;
            id[b[j]]=j-1;
            swap(b[j-1],b[j]);
            g.push_back({1,j-1});
            if(g.size()>mx){z=1;break;}
        }
        if(z) break;
    }
    if(!z){
        printf("2 %d\n",(int)g.size());
        for(pair<int,int> i:g) printf("%d %d\n",i.first,i.second);
        return 0;
    }
    int h=sqrt(n);
    if(6<=h) sol(6);
    if(15<=h) sol(15);
    if(46<=h) sol(46);
    if(101<=h) sol(101);
    sol(h);
    return 0;
}